#include"xh_19.h"

int main()
{
	int n;
	cin >> n;
	vector<Student> students;
	for (int i = 0;i < n;i++)
	{
		string name;
		int score;
		cin >> name >> score;
		students.emplace_back(name, score);
	}

	sort(students.begin(), students.end(), compareStudents);

	for (const auto& student : students)
	{
		cout << student.getName() << " " << student.getName() << endl;
	}

	return 0;
}